package com.space.rabbitmq.receiver;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;


/**
 * 消息消费者3
 *
 * @author zhanglei
 */
@Component
public class ThirdConsumer {

    /**
     * queues  指定从哪个队列（queue）订阅消息
     * @param message
     */
    @RabbitListener(queues = {"third-queue"})
    public void handleMessage(String msg, Channel channel, Message message) throws IOException {
        // 处理消息
        System.out.println("ThirdConsumer --- handleMessage：" + message);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }
}
